package br.usp.ime.servicosusp;

import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;

import br.usp.ime.servicosusp.database.DataBaseHelper;
import android.app.Application;
import android.graphics.drawable.Drawable;

public class servicosUsp extends Application {
	
	public static DataBaseHelper dbHelper;
	public static servicosUsp instance;	
	public HashMap<String, Drawable> loadedImagesBuffer;
	
	public static servicosUsp getInstance() {
		return instance;
	}	

	@Override
	public void onCreate() {
		servicosUsp.instance=this;
		//createDbHelper();
		createDbHelperTestEnviroment();
		loadedImagesBuffer=new HashMap<String, Drawable>();
	} 

	private void createDbHelperTestEnviroment() {
		// TODO Auto-generated method stub
		this.getBaseContext().deleteDatabase("EP2012");
		dbHelper=new DataBaseHelper(this.getBaseContext());
		Tests.insertData();
	}

	private void createDbHelper(){
		dbHelper=null;
		//Configure Database;
		this.getBaseContext().deleteDatabase("EP2012");
		dbHelper=new DataBaseHelper(this.getBaseContext());
		
		try {
			dbHelper.createDataBase();
			dbHelper.openDataBase();	
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
